//
// Created by liangfuqiang on 2021/12/12.
//
#include <stdio.h>

int n, my_union[105];

void init(int x) {
    for (int i = 1; i <= x; ++i) {
        my_union[i] = i;
    }
}

int find_root(int val) {
    if (my_union[val] == val) {
        return val;
    }
    return my_union[val] = find_root(my_union[val]);
}

void merge(int a, int b) {
    int r_a = find_root(a), r_b = find_root(b);
    if (r_a != r_b) {
        my_union[r_a] = r_b;
    }
}

int query(int a, int b) {
    return find_root(a) == find_root(b);
}

int main() {
    scanf("%d", &n);
    init(n);
    for (int i = 0; i < 100; ++i) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        if (a) {
            merge(b, c);
        } else {
            if (query(b, c)) {
                printf("same");
            } else {
                printf("different");
            }
        }
    }

    return 0;
}